<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    #first {color: green;}
    #second {color: red;}
  </style>
</head>
<body>
  <ul id="first"></ul>
  <script>
    function addMessage(element, message){
      return new Promise((resolve,rejct)=>{
        let messageElement = document.createElement("li")
        messageElement.textContent = message
        element.appendChild(messageElement)
        setTimeout(()=>{
          resolve()
        },500)
      })

    }
    const first = document.querySelector("#first")
    addMessage(first,"Page loading")
  </script>
  <ul id="second"></ul>
  <script>
    document.body.addEventListener("mousemove",async ()=>{
      let li =  document.querySelectorAll("#second>li")
      const second =document.querySelector("#second")
      if(li.length<10){
        addMessage(second, "Event:mousemove")
      }
    });
    document.body.addEventListener("click",()=>{
      addMessage(second,"Event:click")
    })
  </script>
</body>
</html>